package org.msfj.hospital.controller;

import org.msfj.hospital.model.HospitalExpert;
import org.msfj.hospital.vo.HospitalExpertVo;
import org.msfj.hospital.service.HospitalExpertService;
import org.msfj.common.base.BaseController;
import org.msfj.common.model.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import com.github.pagehelper.PageInfo;
import java.util.List;

/**
 * @Description: 医院专家信息controller
 * @Author: like
 * @Email: like@deyatong.com
 * @Date: 2018-08-10 14:12:03
 * @Version: 1.0
 * @Created in idea by autoCode
 */
@Api(value = "医院专家信息接口", tags = "医院专家信息接口")
@RestController
@RequestMapping("/hospitalExpert/")
public class  HospitalExpertController extends BaseController{

    @Autowired
    private HospitalExpertService hospitalExpertService;

    /**
     * 添加医院专家信息
     *
     * @param hospitalExpertVo
     * @return CommonResult.ok(HospitalExpertVo)
     */
    @PostMapping("/add")
    @ApiOperation(value = "添加医院专家信息",notes = "添加医院专家信息")
    @ApiImplicitParam(value = "hospitalExpertVo",name = "hospitalExpertVo",dataType = "org.msfj.hospital.vo.HospitalExpertVo",paramType = "query")
    public CommonResult addHospitalExpert(HospitalExpertVo hospitalExpertVo){
        HospitalExpert hospitalExpert = hospitalExpertService.saveOrEdit(hospitalExpertVo);
        return CommonResult.ok(hospitalExpertService.setOtherProperties(hospitalExpert));
    }

    /**
     * 修改医院专家信息
     *
     * @param hospitalExpertVo
     * @return CommonResult.ok(HospitalExpertVo)
     */
    @PostMapping("/edit")
    @ApiOperation(value = "修改医院专家信息",notes = "修改医院专家信息")
    @ApiImplicitParam(value = "hospitalExpertVo",name = "hospitalExpertVo",dataType = "org.msfj.hospital.vo.HospitalExpertVo",paramType = "query")
    public CommonResult editHospitalExpert(HospitalExpertVo hospitalExpertVo){
        HospitalExpert hospitalExpert = hospitalExpertService.saveOrEdit(hospitalExpertVo);
        return CommonResult.ok(hospitalExpertService.setOtherProperties(hospitalExpert));
    }

    /**
     * 逻辑删除医院专家信息
     *
     * @param hospitalExpertVo
     * @return CommonResult.ok(HospitalExpertVo)
     */
    @PostMapping("/del")
    @ApiOperation(value = "逻辑删除医院专家信息",notes = "逻辑删除医院专家信息")
    @ApiImplicitParam(value = "hospitalExpertVo",name = "hospitalExpertVo",dataType = "org.msfj.hospital.vo.HospitalExpertVo",paramType = "query")
    public CommonResult delHospitalExpert(HospitalExpertVo hospitalExpertVo){
        HospitalExpert hospitalExpert = hospitalExpertService.delById(hospitalExpertVo);
        return CommonResult.ok(hospitalExpertService.setOtherProperties(hospitalExpert));
    }

    /**
     * 逻辑删除系统用户信息
     * @param ids
     * @return CommonResult.ok()
     */
    @PostMapping("/dels")
    @ApiOperation(value = "逻辑删除医院专家信息",notes = "逻辑删除医院专家信息")
    @ApiImplicitParam(value = "ids[]",name = "ids[]",dataType = "java.util.List",paramType = "query")
    public CommonResult delSysUsers(@RequestParam(value = "ids[]",required = false) List<String> ids){
        HospitalExpert hospitalExpert = new HospitalExpert();
        hospitalExpertService.delByIds(ids,hospitalExpert);
        return CommonResult.ok();
    }

    /**
     * 真实删除医院专家信息
     *
     * @param hospitalExpertVo
     * @return CommonResult.ok()
     */
    @PostMapping("/delete")
    @ApiOperation(value = "真实删除医院专家信息",notes = "真实删除医院专家信息")
    @ApiImplicitParam(value = "hospitalExpertVo",name = "hospitalExpertVo",dataType = "org.msfj.hospital.vo.HospitalExpertVo",paramType = "query")
    public CommonResult deleteHospitalExpert(HospitalExpertVo hospitalExpertVo){
        hospitalExpertService.trueDelById(hospitalExpertVo);
        return CommonResult.ok();
    }

    /**
     * 根据id查找医院专家信息
     *
     * @param hospitalExpertVo
     * @return CommonResult.ok(HospitalExpertVo)
     */
    @GetMapping("/get")
    @ApiOperation(value = "根据id查找医院专家信息",notes = "根据id查找医院专家信息")
    @ApiImplicitParam(value = "hospitalExpertVo",name = "hospitalExpertVo",dataType = "org.msfj.hospital.vo.HospitalExpertVo",paramType = "query")
    public CommonResult getHospitalExpert(HospitalExpertVo hospitalExpertVo){
        HospitalExpert hospitalExpert = hospitalExpertService.getById(hospitalExpertVo.getId());
        return CommonResult.ok(hospitalExpertService.setOtherProperties(hospitalExpert));
    }

    /**
     * 根据翻页参数、搜索参数查找医院专家信息
     *
     * @param hospitalExpertVo
     * @param page 当前第几页
     * @param rows 每页多少条记录
     * @return CommonResult.ok(PageInfo<HospitalExpertVo>)
     */
    @GetMapping("/list")
    @ApiOperation(value = "根据翻页参数、搜索参数查找医院专家信息",notes = "根据翻页参数、搜索参数查找医院专家信息")
    @ApiImplicitParams({
        @ApiImplicitParam(value = "hospitalExpertVo",name = "hospitalExpertVo",dataType = "org.msfj.hospital.vo.HospitalExpertVo",paramType = "query"),
        @ApiImplicitParam(name = "page",value = "page",dataType = "Integer",paramType = "path"),
        @ApiImplicitParam(name = "rows",value = "rows",dataType = "Integer",paramType = "path")
    })
    public CommonResult findHospitalExpertList(HospitalExpertVo hospitalExpertVo, Integer page, Integer rows){
        PageInfo<HospitalExpertVo> hospitalExpertVoPageInfo = hospitalExpertService.getByHospitalExpert(hospitalExpertVo,page,rows);
        return CommonResult.ok(hospitalExpertVoPageInfo);
    }

    /**
     * 根据搜索参数查找所有医院专家信息
     *
     * @param hospitalExpertVo
     * @return CommonResult.ok(List<HospitalExpertVo>)
     */
    @GetMapping("/getAll")
    @ApiOperation(value = "根据搜索参数查找所有医院专家信息",notes = "根据搜索参数查找所有医院专家信息")
    @ApiImplicitParam(value = "hospitalExpertVo",name = "hospitalExpertVo",dataType = "org.msfj.hospital.vo.HospitalExpertVo",paramType = "query")
    public CommonResult getAllHospitalExpert(HospitalExpertVo hospitalExpertVo){
        List<HospitalExpertVo> hospitalExpertVoList = hospitalExpertService.getAllHospitalExpert(hospitalExpertVo);
        return CommonResult.ok(hospitalExpertVoList);
    }
}
